package 剑指offer.Month7_07.day16;

public class 二叉树的深度 {
    int treeHeight = 0;
    public int TreeDepth(TreeNode root) {
        if(root == null) return 0;
        backstacking(root,0);
        return treeHeight +1;
    }

    public void backstacking(TreeNode root,int height){
        if(root == null) return;
        if(height > treeHeight) treeHeight++;
        backstacking(root.left,height + 1);
        backstacking(root.right,height + 1);
    }
}
